package pub.xspace.nova.system.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.websocket.server.PathParam;
import pub.xspace.nova.common.constant.Constant;
import pub.xspace.nova.common.controller.BaseController;
import pub.xspace.nova.common.domain.AjaxResult;
import pub.xspace.nova.common.exception.NovaException;
import pub.xspace.nova.system.service.SysUserService;

/**
 * 系统用户管理控制器
 * 
 * @author HeJianrong
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

	@Resource
	private SysUserService sysUserService;

	/**
	 * 测试方法，获取用户对象
	 * 
	 * @param username
	 * @return
	 */
	@GetMapping("/getuser/{username}")
	public AjaxResult getUser(@PathVariable("username") String username) {
		if ("admin".equals(username)) {
			return success("成功获取用户数据", sysUserService.getByUsername("admin"));
		} else {
			throw new NovaException(Constant.RESULT_FAIL_CODE, "获取用户失败");
		}
	}
}
